/*
 * colors.fx
 *
 * Created on 23-dic-2009, 15:59:03
 */

package ProgramSamples;

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;


def size = 19; // the color box size
def space = 3; // the space between boxes

def width  = 10;
def height = 14;

def colors = [
    "aliceblue",       "antiquewhite",     "aqua",                 "aquamarine",
    "azure",           "beige",            "bisque",               "black",
    "blanchedalmond",  "blue",             "blueviolet",           "brown",
    "burlywood",       "cadetblue",        "chartreuse",           "chocolate",
    "coral",           "cornflowerblue",   "cornsilk",             "crimson",
    "cyan",            "darkblue",         "darkcyan",             "darkgoldenrod",
    "darkgreen",       "darkgrey",         "darkkhaki",            "darkmagenta",
    "darkolivegreen",  "darkorange",       "darkorchid",           "darkred",
    "darksalmon",      "darkseagreen",     "darkslateblue",        "darkslategrey",
    "darkturquoise",   "darkviolet",       "deeppink",             "deepskyblue",
    "dimgrey",         "dodgerblue",       "firebrick",            "floralwhite",
    "forestgreen",     "fuchsia",          "gainsboro",            "ghostwhite",
    "gold",            "goldenrod",        "green",                "greenyellow",
    "grey",            "honeydew",         "hotpink",              "indianred",
    "indigo",          "ivory",            "khaki",                "lavender",
    "lavenderblush",   "lawngreen",        "lemonchiffon",         "lightblue",
    "lightcoral",      "lightcyan",        "lightgoldenrodyellow", "lightgreen",
    "lightgrey",       "lightpink",        "lightsalmon",          "lightseagreen",
    "lightskyblue",    "lightslategrey",   "lightsteelblue",       "lightyellow",
    "lime",            "limegreen",        "linen",                "magenta",
    "maroon",          "mediumaquamarine", "mediumblue",           "mediumorchid",
    "mediumpurple",    "mediumseagreen",   "mediumslateblue",      "mediumspringgreen",
    "mediumturquoise", "mediumvioletred",  "midnightblue",         "mintcream",
    "mistyrose",       "moccasin",         "navajowhite",          "navy",
    "oldlace",         "olive",            "olivedrab",            "orange",
    "orangered",       "orchid",           "palegoldenrod",        "palegreen",
    "paleturquoise",   "palevioletred",    "papayawhip",           "peachpuff",
    "peru",            "pink",             "plum",                 "powderblue",
    "purple",          "red",              "rosybrown",            "royalblue",
    "saddlebrown",     "salmon",           "sandybrown",           "seagreen",
    "seashell",        "sienna",           "silver",               "skyblue",
    "slateblue",       "slategrey",        "snow",                 "springgreen",
    "steelblue",       "tan",              "teal",                 "thistle",
    "tomato",          "turquoise",        "violet",               "wheat",
    "white",           "whitesmoke",       "yellow",               "yellowgreen"
];

var color = "white";

Stage {
    title: "Colors";
    scene: Scene {
        fill: bind Color.web(color);
        width: space + (space + size) * width
        height: space + (space + size) * height
        content:
        for (currentColor in colors)
        Rectangle {
            def j: Integer = indexof currentColor / width;
            def i: Integer = indexof currentColor - j * width;
            fill: Color.web(currentColor)
            x: space + (space + size) * i
            y: space + (space + size) * j
            width: size
            height: size
            onMouseClicked: function(event) {
                color = currentColor
            }//OnMouseClicked


        }//Rectangle

    }//Scene
}//Stage